<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="../templates/ui.xhtml">
	
	<ui:define name="content">

		<h1 class="title ui-widget-header ui-corner-all">Menubar</h1>
		<div class="entry">
			<p>Menubar brings the desktop application menubars to JSF. Using menuitems, it is very easy to execute both ajax and non-ajax actions
			as well as directly navigating to other resources.</p>
			
			<h:form>
				
				<p:growl id="messages"/>
				
                <p:menubar>
					<p:submenu label="File" icon="ui-icon-document">
						<p:submenu label="New" icon="ui-icon-contact">
							<p:menuitem value="Project" url="#" />
							<p:menuitem value="Other" url="#" />
						</p:submenu>
						<p:menuitem value="Open" url="#" />
                        <p:separator />
						<p:menuitem value="Quit" url="#" />
					</p:submenu>
					
					<p:submenu label="Edit" icon="ui-icon-pencil">
						<p:menuitem value="Undo" url="#" icon="ui-icon-arrowreturnthick-1-w" />
						<p:menuitem value="Redo" url="#" icon="ui-icon-arrowreturnthick-1-e" />
					</p:submenu>
					
					<p:submenu label="Help" icon="ui-icon-help">
						<p:menuitem value="Contents" url="#" />
						<p:submenu label="Search" icon="ui-icon-search">
							<p:submenu label="Text">
								<p:menuitem value="Workspace" url="#" />
							</p:submenu>
							<p:menuitem value="File" url="#" />
						</p:submenu>
					</p:submenu>
					
					<p:submenu label="Actions" icon="ui-icon-gear">
						<p:submenu label="Ajax" icon="ui-icon-refresh">
							<p:menuitem value="Save" actionListener="#{buttonBean.save}" icon="ui-icon-disk" update="messages"/>
							<p:menuitem value="Update" actionListener="#{buttonBean.update}" icon="ui-icon-arrowrefresh-1-w" update="messages"/>
						</p:submenu>
						<p:submenu label="Non-Ajax" icon="ui-icon-newwin">
							<p:menuitem value="Delete" actionListener="#{buttonBean.delete}" icon="ui-icon-close" update="messages" ajax="false"/>
						</p:submenu>
					</p:submenu>

                    <p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" />
				</p:menubar>
				
			</h:form>
		
			<h3>Source</h3>
			<p:tabView>
				<p:tab title="menubar.xhtml">
<pre name="code" class="xml">
&lt;h:form&gt;

    &lt;p:growl id="messages"/&gt;

    &lt;p:menubar&gt;
        &lt;p:submenu label="File" icon="ui-icon-document"&gt;
            &lt;p:submenu label="New" icon="ui-icon-contact"&gt;
                &lt;p:menuitem value="Project" url="\#" /&gt;
                &lt;p:menuitem value="Other" url="\#" /&gt;
            &lt;/p:submenu&gt;
            &lt;p:menuitem value="Open" url="\#" /&gt;
            &lt;p:separator /&gt;
            &lt;p:menuitem value="Quit" url="\#" /&gt;
        &lt;/p:submenu&gt;

        &lt;p:submenu label="Edit" icon="ui-icon-pencil"&gt;
            &lt;p:menuitem value="Undo" url="\#" icon="ui-icon-arrowreturnthick-1-w" /&gt;
            &lt;p:menuitem value="Redo" url="\#" icon="ui-icon-arrowreturnthick-1-e" /&gt;
        &lt;/p:submenu&gt;

        &lt;p:submenu label="Help" icon="ui-icon-help"&gt;
            &lt;p:menuitem value="Contents" url="\#" /&gt;
            &lt;p:submenu label="Search" icon="ui-icon-search"&gt;
                &lt;p:submenu label="Text"&gt;
                    &lt;p:menuitem value="Workspace" url="\#" /&gt;
                &lt;/p:submenu&gt;
                &lt;p:menuitem value="File" url="\#" /&gt;
            &lt;/p:submenu&gt;
        &lt;/p:submenu&gt;

        &lt;p:submenu label="Actions" icon="ui-icon-gear"&gt;
            &lt;p:submenu label="Ajax" icon="ui-icon-refresh"&gt;
                &lt;p:menuitem value="Save" actionListener="\#{buttonBean.save}" icon="ui-icon-disk" update="messages"/&gt;
                &lt;p:menuitem value="Update" actionListener="\#{buttonBean.update}" icon="ui-icon-arrowrefresh-1-w" update="messages"/&gt;
            &lt;/p:submenu&gt;
            &lt;p:submenu label="Non-Ajax" icon="ui-icon-newwin"&gt;
                &lt;p:menuitem value="Delete" actionListener="\#{buttonBean.delete}" icon="ui-icon-close" update="messages" ajax="false"/&gt;
            &lt;/p:submenu&gt;
        &lt;/p:submenu&gt;

        &lt;p:menuitem value="Quit" url="http://www.primefaces.org" icon="ui-icon-close" /&gt;
    &lt;/p:menubar&gt;

&lt;/h:form&gt;
			</pre>
				</p:tab>
				
				<p:tab title="MenuBean.java">
<pre name="code" class="xml">
package org.primefaces.examples.view;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class MenuBean {
	
	public void save(ActionEvent actionEvent) {
		addMessage("Data saved");
	}
	
	public void update(ActionEvent actionEvent) {
		addMessage("Data updated");
	}
	
	public void delete(ActionEvent actionEvent) {
		addMessage("Data deleted");
	}
	
	public void addMessage(String summary) {
		FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);
		FacesContext.getCurrentInstance().addMessage(null, message);
	}
}

			</pre>
				</p:tab>
			</p:tabView>
			
		
		</div>

	</ui:define>
</ui:composition>